﻿@{
    Layout = "";
}
<div ng-controller="WxConfigController">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <form name="formValidate" ng-submit="submitForm()" novalidate="" class="form-validate form-horizontal">
                    <!-- START panel-->
                    <div class="panel panel-default" ng-class="{ 'whirl standard': isLoading }">
                        <div class="panel-body">
                            <fieldset class="b0">
                                <legend>基础配置</legend>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">Url</label>
                                    <div class="col-sm-4">
                                        <span class="text-box" ng-bind="ResponseData.Url"></span>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">Token</label>
                                    <div class="col-sm-4">
                                        <span class="text-box" ng-bind="ResponseData.Token"></span>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">AppId</label>
                                    <div class="col-sm-4">
                                        <input maxlength="50" type="text" name="appid" required="" ng-model="ResponseData.AppId" class="form-control" />
                                        <span ng-show="validateInput('appid', 'required')" class="text-danger">请输入AppId</span>
                                    </div>
                                    <div class="col-sm-4">
                                        <h4 class="text-danger">*</h4>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">AppSecret</label>
                                    <div class="col-sm-4">
                                        <input maxlength="100" type="text" name="appsecret" required="" ng-model="ResponseData.AppSecret" class="form-control" />
                                        <span ng-show="validateInput('appsecret', 'required')" class="text-danger">请输入AppSecret</span>
                                    </div>
                                    <div class="col-sm-4">
                                        <h4 class="text-danger">*</h4>
                                    </div>
                                </div>
                            </fieldset>
                        </div>
                        
                    </div>
                    <!-- END panel-->
                    <!-- START panel-->
                    <div class="panel panel-default" ng-class="{ 'whirl standard': isLoading }">
                        <div class="panel-body">
                            <fieldset class="b0">
                                <legend>微信支付配置</legend>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">PartnerID</label>
                                    <div class="col-sm-4">
                                        <input maxlength="50" type="text" name="partnerID" ng-model="ResponseData.PartnerID" class="form-control" />
                                        @*<span ng-show="validateInput('partnerID', 'required')" class="text-danger">请输入PartnerID</span>*@
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">PartnerKey</label>
                                    <div class="col-sm-4">
                                        <input maxlength="100" type="text" name="partnerKey" ng-model="ResponseData.PartnerKey" class="form-control" />
                                        @*<span ng-show="validateInput('partnerKey', 'required')" class="text-danger">请输入PartnerKey</span>*@
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">PaySignKey</label>
                                    <div class="col-sm-4">
                                        <input maxlength="100" type="text" name="paySignKey" ng-model="ResponseData.PaySignKey" class="form-control" />
                                        @*<span ng-show="validateInput('paySignKey', 'required')" class="text-danger">请输入PaySignKey</span>*@
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">是否开启微信支付</label>
                                    <div class="col-sm-4">
                                        <label class="switch switch-lg">
                                            <input type="checkbox" checked="checked" ng-model="ResponseData.IsOpenWxPay">
                                            <span></span>
                                        </label>
                                    </div>
                                </div>
                            </fieldset>
                        </div>

                    </div>
                    <!-- END panel-->
                    <div class="text-right">
                        <button type="submit" class="btn btn-primary">保 存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    App.controller('WxConfigController', ["$scope", "$state", "$http", "Notify", "$rootScope",
        function ($scope, $state, $http, Notify, $rootScope) {
            'use strict';
            $scope.submitted = false;
            $scope.isLoading = true;
            $scope.validateInput = function (name, type) {
                var input = $scope.formValidate[name];
                return (input.$dirty || $scope.submitted) && input.$error[type];
            };


            //数据初始化
            $http.post("/WxSet/GetConfig", {}).then(function (response) {
                $scope.ResponseData = response.data;
                if (!$scope.ResponseData) {
                    $scope.ResponseData = {};
                }
                $scope.isLoading = false;
            });
            //console.log("342423423423423");
            // 提交
            $scope.submitForm = function () {
                $scope.submitted = true;
                if ($scope.formValidate.$valid) {
                    $http.post("/WxSet/WxConfigSubmit", { wxconfig: $scope.ResponseData }).then(function (returnData) {
                        if (returnData.data.isSuccess) {
                            Notify.alert('操作成功!', { status: 'success' });
                        } else {
                            Notify.alert(returnData.data.msg, { status: 'warning' });
                        }
                    });
                } else {
                    //alert("false");
                    return false;
                }
            };

        }]);
</script>
